import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

// 全局路由
export const globalRoutes = [

	// 登录
	{
		path: '/login',
		component: () => import('@/views/login')
	},

	// 首页
	{
		path: '',
		component: () => import('@/views/Main'),
		redirect: '/dashboard',
		children: [
			// 数据统计
			{
				path: '/dashboard',
				component: () => import('@/components/Dashboard'),
			},

			{
				path: '/operMember',
				component: () => import('@/components/SysMember')
			},

			{
				path: '/operLog',
				component: () => import('@/components/SysMemberLog')
			},

			// 修改用户
			{
				path: '/operUser',
				component: () => import('@/components/OperUser')
			},

			// 修改视频
			{
				path: '/operVideo',
				component: () => import('@/components/OperVideo')
			},

			// 修改轮播图
			{
				path: '/operBanner',
				component: () => import('@/components/OperBanner')
			},

			// 管理评论
			{
				path: '/operComments',
				component: () => import('@/components/OperComment')
			},

			// 修改菜单
			{
				path: '/operMenu',
				component: () => import('@/components/OperMenu')
			},

			// 修改标签
			{
				path: '/operLabel',
				component: () => import('@/components/OperLabel')
			},

			// API 接口访问记录
			{
				path: '/apiLog',
				component: () => import('@/components/ApiLog')
			},

			// 平台访问日志
			{
				path: '/videoLog',
				component: () => import('@/components/VideoLog')
			}
		]
	},



]

// 防止连续点击多次路由报错
let routerPath = Router.prototype.push;
Router.prototype.push = function push(location) {
	return routerPath.call(this, location).catch(err => err)
}

export default new Router({
	mode: 'history', // 去掉url中的#
	routes: globalRoutes
});
